/**
 * @pcap.h
 * @author  Jed Wong <zyowong@gmail.com>
 * @version 1.0
 *
 * @section DESCRIPTION
 *
 * The pcap_packet.h file  include a class that represents a pcap packet.
 */
#ifndef PCAP_PACKET_H
#define PCAP_PACKET_H
#include "pcap.h"
#include <fstream>
using namespace std;
class Qpcap_packet
{
public:
    Qpcap_packet();
private:

    /// pcap packet header
    pcap_pkthdr  pcappacketheader;
    /// Mac  packet header
    eth_hdr   ethnetheader;
    /// IP  packet header
    ip_hdr  ipheader;
    /// TCP packet header
    tcp_hdr tcpheader;
    /// UDP packet header
    udp_hdr udpheader;


public:
    ///     @brief init the Pcap packet
    ///     @param infilestream  the input datastream
    ///     @return    if it is IP packet and transmission is TCP or UDP return true; others return false
    bool setPcap_packet(ifstream &infilestream);
    ///     @brief return the pcap packet header
    ///     @return    the pcap packet header
    pcap_pkthdr* getPcappacketheader();
    ///     @brief return the ethnet packet header
    ///     @return    the ethnet packet header
    eth_hdr* getEthnetheader();
    ///     @brief return the Ip packet header
    ///     @return    the Ip packet header
    ip_hdr* getIpheader();
    ///     @brief return the Tcp packet header
    ///     @return    the Tcp packet header
    tcp_hdr* getTcpheader();


    ///     @brief return the cap length of the pcap packet
    ///     @return    cap length of the pcap packet
    unsigned long getPcap_packetcaplen();
    ///     @brief return the cap length of the pcap packet
    ///     @return    cap length of the pcap packet
    unsigned short getMac_eth_type();
    ///     @brief return the cap length of the pcap packet
    ///     @return    cap length of the pcap packet
   unsigned char getIP_Protocl_type();

};

#endif // PCAP_PACKET_H
